public class InsertSort {
    public static void insertSort(int[] arr){
        for (int i = 1; i < arr.length; i++) {
            int inVal=arr[i];
            int index=i;
            while(index>0&&arr[index-1]>arr[index]){
                int tmp=arr[index-1];
                arr[index-1]=arr[index];
                arr[index]=tmp;
                index--;
            }
        }
    }

    public static void main(String[] args) {
        int[] arr={9,8,7,6,5,4,10,3,2,1};
        insertSort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
